﻿using DevExpress.XtraReports.UI;
using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Smart.Common.Report
{
    public class Helper
    {
        public const int ICC_USEREX_CLASSES = 0x200;

        [DllImport("kernel32.dll")]
        public static extern bool FreeLibrary(IntPtr hModule);
        public static string GetReportPath(XtraReport fReport, string ext)
        {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            string name = fReport.Name;
            if (name.Length == 0)
            {
                name = fReport.GetType().Name;
            }
            return Path.Combine(Path.GetDirectoryName(executingAssembly.Location), name + "." + ext);
        }

        [DllImport("comctl32.dll")]
        public static extern bool InitCommonControlsEx(INITCOMMONCONTROLSEX icc);
        public static Image LoadImage(string name)
        {
            Bitmap bitmap = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("XtraReportsDemos." + name));
            bitmap.MakeTransparent(Color.Magenta);
            return bitmap;
        }

        [DllImport("kernel32.dll")]
        public static extern IntPtr LoadLibrary(string libname);
        private static void PatchConnection(string propertyName, string startupPath)
        {
            MessageBox.Show("Đang ph\x00e1t triển");
        }

        public static void PatchConnections(string startupPath)
        {
            MessageBox.Show("Đang ph\x00e1t triển");
        }

        private static void PatchPath(string propertyName, string startupPath)
        {
            MessageBox.Show("Đang ph\x00e1t triển");
        }

        [StructLayout(LayoutKind.Sequential, Pack = 1)]
        public class INITCOMMONCONTROLSEX
        {
            public int dwSize = 8;
            public int dwICC;
        }
    }
}
